<?php
namespace App\JdLib;
use App\Config\config;

class demo{

    //订单查询
    public function Order($orderid)
    {
        $c = new JdClient;
        $c->connectUrl 	= "https://openapi.jddj.com/djapi/order/es/query";//平台的接口地址
        $c->appkey 		= config::$appkey;//应用的app_key
        $c->appsecret 	= config::$appsecret;//应用的app_secret
        $c->token 		= config::$jdtoken;//应用的token。
       return $this->OrderCancel($c,$orderid);
    }

    //订单确认
    public function confirm($orderid,$bool)
    {
        $c = new JdClient;
        $c->connectUrl 	= "https://openapi.jddj.com/djapi/ocs/orderAcceptOperate";//平台的接口地址
        $c->appkey 		= config::$appkey;//应用的app_key
        $c->appsecret 	= config::$appsecret;//应用的app_secret
        $c->token 		= config::$jdtoken;//应用的token。

        $resp = $c->execute_conf($orderid,$bool);
        return $resp;


    }

    //订单查询
   public function OrderCancel($client,$orderid)
   {

    $req = new OrderCancel;
    $req->setOrderId($orderid);
    $req->setOperTime(date('Y-m-d H:i:s'));
    $resp = $client->execute($req);
    return $resp;

 }


}
